Closed Bug 1216041 Opened 10 years ago Closed 10 years ago

add ranged iterator support to mozilla::{Array,RangedArray,EnumerationArray}

Categories

(Core :: MFBT, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla44
Tracking Status
firefox44 --- fixed

People

(Reporter: heycam, Assigned: heycam)

References

Details

Attachments

(1 file)

I want to use ranged for-loop syntax on an EnumeratedArray. And I may as well add support to Array and RangedArray while I'm at it.
Assignee: nobody → cam
Status: NEW → ASSIGNED
Attachment #8675513 - Flags: review?(nfroyd)
Blocks: 1216043
Comment on attachment 8675513 [details] [diff] [review] Add ranged iterator support to mozilla::{Array,RangedArray,EnumerationArray}. Review of attachment 8675513 [details] [diff] [review]: ----------------------------------------------------------------- r=me with nitpicky consistency changes below. ::: mfbt/EnumeratedArray.h @@ +77,5 @@ > + > + // Methods for range-based for loops. > + iterator begin() { return mArray.begin(); } > + const_iterator begin() const { return mArray.begin(); } > + const_iterator cbegin() const { return mArray.begin(); } Nit: please make this cbegin() for consistency. (Since you use the c* variants below.) ::: mfbt/EnumeratedRange.h @@ +172,5 @@ > > // Create a range to iterate from aBegin to aEnd, exclusive. > +// > +// (Once we can rely on std::underlying_type, we can remove the IntType > +// template parameter.) Feel free to fold these changes to this file into bug 1216038. ::: mfbt/RangedArray.h @@ +46,5 @@ > + > + // Methods for range-based for loops. > + iterator begin() { return mArr.begin(); } > + const_iterator begin() const { return mArr.begin(); } > + const_iterator cbegin() const { return mArr.begin(); } Here too.
Attachment #8675513 - Flags: review?(nfroyd) → review+
(In reply to Nathan Froyd [:froydnj] from comment #2) > > + const_iterator cbegin() const { return mArray.begin(); } > > Nit: please make this cbegin() for consistency. (Since you use the c* > variants below.) Sorry, yes I noticed these locally but forgot to update the patch. > ::: mfbt/EnumeratedRange.h > @@ +172,5 @@ > > > > // Create a range to iterate from aBegin to aEnd, exclusive. > > +// > > +// (Once we can rely on std::underlying_type, we can remove the IntType > > +// template parameter.) > > Feel free to fold these changes to this file into bug 1216038. Will do.
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla44
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: